package org.qiandaosystem.qiandaosystemsource.mapper;

import org.apache.ibatis.annotations.*;
import org.qiandaosystem.qiandaosystemsource.entity.SignRecord;
import java.util.List;

@Mapper
public interface SignRecordMapper {
    
    @Select("SELECT * FROM sign_records WHERE student_id = #{studentId}")
    List<SignRecord> findByStudentId(Integer studentId);
    
    @Select("SELECT * FROM sign_records WHERE activity_id = #{activityId}")
    List<SignRecord> findByActivityId(Integer activityId);
    
    @Select("SELECT * FROM sign_records WHERE activity_id = #{activityId} AND student_id = #{studentId}")
    SignRecord findByActivityIdAndStudentId(Integer activityId, Integer studentId);
    
    @Insert("INSERT INTO sign_records(activity_id, student_id, sign_time, status, detail) " +
            "VALUES(#{activityId}, #{studentId}, #{signTime}, #{status}, #{detail})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(SignRecord record);
} 